<%@page import="com.hhit.collaborative_learning.entity.Data"%>
<%@page import="com.hhit.collaborative_learning.dao.impl.PublicDaoImplMySql"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String dataId=request.getParameter("dataId");
	PublicDaoImplMySql dao=new PublicDaoImplMySql();
	Data data=dao.getDataById(Integer.parseInt(dataId));
	request.setAttribute("data", data);
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="<%=basePath %>css/download.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet"
	href="<%=basePath %>css/index.css">
<script
	src="<%=basePath %>js/jquery-1.11.1.min.js"
	type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="<%=basePath %>css/News-nav.css">
<!-- toolbar nav -->

<script language='JavaScript' type='text/javascript'
	src='<%=basePath %>js/jquery.form.js'></script>
<script language='JavaScript' type='text/javascript'
	src='<%=basePath %>js/jquery.cookie.js'></script>
<script type="text/javascript">
var sourceid=0;
var point='<%=data.dataPoint%>';
var dataUserId='<%=data.dataUId%>';
</script>
</head>
<body>
	<div class="news-nav">
		<div class="container clearfix">
			<div class="nav-bar">
				<a href="<%=basePath %>download/download.jsp" target="_top" class="current">首页</a> 
				<a href="<%=basePath %>download/mydata.jsp" onclick="checkLogin()">我的资源</a>
				<a href="<%=basePath%>download/search.jsp?type=3" target="_blank">搜索</a>
			</div>
		</div>
	</div>
	<div id="wrap">
		<link rel="stylesheet" type="text/css"
			href="<%=basePath %>css/bootstrap.css">
		<link rel="stylesheet" type="text/css"
			href="<%=basePath %>css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css"
			href="<%=basePath %>css/common_download2.css">
		<link rel="stylesheet" type="text/css"
			href="<%=basePath %>css/nav.css">
		<link rel="stylesheet" type="text/css"
			href="<%=basePath %>css/panels.css">
		<link rel="stylesheet" type="text/css" href="<%=basePath %>css/style_download.css">
		<link href="<%=basePath %>css/source_detail.css" rel="stylesheet">
		<link href="<%=basePath %>css/detail-download.css" rel="stylesheet">
		<div class="bd clearfix">
			<!-- 导航下的广告 -->
			<div class="article">
				<!-- 728*90 -->
				<div class="bread-crumbs mb-bg">
					<span><a href="<%=basePath%>download/download.jsp">首页</a></span><em class="to-icon">&gt;</em><span><a
						href="<%=basePath%>download/category.jsp?type=${data.dataType}">${data.dataType_CN}</a></span><em class="to-icon">&gt;</em><span>${data.dataName}</span>
				</div>
				<h3 class="title mb-bg"
					title='${data.dataName}'>${data.dataName}</h3>
				<div class="author-share mb-bg clearfix">
					<div class="pull-left">
						<a href="/user/txwang2008" class="user_name">${data.dataUserName}</a>${data.dataTime}上传
					</div>
				</div>
				<div class="cut_intro" style="overflow:hidden;">${data.dataDesc}</div>
				<!--  <p class="dis mb-bg">  -->
				<!--  </p>  -->

				<div class="information mb-bg clearfix">
					<div class="info">
						<div class="wraper-info">
							<ul class="size-type clearfix">
								<li><strong>资源积分：</strong><span>${data.dataPoint}分</span></li>
								<li><strong>下载次数：</strong><span>${data.dataDownloadNum}</span></li>
								<li><strong>资源类型：</strong><span>${data.dataCategory}</span></li>
								<li><strong>资源大小：</strong><span>${data.dataSize}</span></li>
<!-- 								<li><strong>资源得分：</strong> <span class="stars"> <span -->
<!-- 										class="star-def"></span> <span style="width:75px" -->
<!-- 										class="star-yellow"></span> -->
<!-- 								</span></li> -->
<!-- 								<li><span>(67位用户参与评分)</span></li> -->
							</ul>
							<ul class="tags-share">
								<c:forEach items="${data.dataTag}" var="tag">
									<li><a href="javascript:void(0);" class="tag">${tag}</a></li>
								</c:forEach>
							</ul>
						</div>
						<div class="enter-link">
							<a href="javascript:void(0);" onclick="downloadFile(this);" class="into-download">下载 </a>
						</div>
						<div class="operating">
							<link rel="stylesheet"
								href="<%=basePath %>css/popover.css">
							<a href="javascript:void(0);" class="collect" id="btn_fav"
								rel="nofollow"
								onclick="">收藏(${data.dataCollNum})</a>
							<a href="#comment" class="comment"
								onclick="">评论(${data.dataComNum})</a>
							<div class="download_rep_suc" style="display:none;" id="rep_suc"></div>
						</div>
					</div>

					<script type="text/javascript">
					function checkLogin(){
						if($.cookie("userId")){
							return true;
						}
						if(confirm("下载需要登录，是否登录?")){
							var links=top.location.href.substring(7).split("/");
							top.location.href="<%=basePath%>login.jsp?link="+encodeURIComponent(links[2]+"/"+links[3]);
							return false;
						}
						return false;
					}
					function DownLoad() {
		            	var form = $("<form>");   //定义一个form表单
			            form.attr('style', 'display:none');   //在form表单中添加查询参数
			            form.attr('target', '');
			            form.attr('method', 'post');
			            form.attr('action', "<%=basePath%>DownloadFileServlet");
			            var input1 = $('<input>');
			            input1.attr('type', 'hidden');
			            input1.attr('name', 'realDataName');
			            input1.attr('value', "<%=data.realDataName%>");
			            var input2 = $('<input>');
			            input2.attr('type', 'hidden');
			            input2.attr('name', 'storeDataName');
			            input2.attr('value', "<%=data.storeDataName%>");
			            $('body').append(form);  //将表单放置在web中
			            form.append(input1);   //将查询参数控件提交到表单上
			            form.append(input2);   //将查询参数控件提交到表单上
			            form.submit();
			
			         }
					function downloadFile(e){
						var userId=$.cookie("userId");
						if(checkLogin()){
							$.get("<%=basePath%>ValidatePointServlet?userId="+userId,function(data,status){
								var haspoint=parseInt(data);
								var needPoint=parseInt(point);
								if(haspoint>=needPoint){
									if(confirm("下载该资源需要消耗"+needPoint+"积分，是否确定下载?")){
										$.post("<%=basePath%>DownloadServlet",{point:needPoint,userId:userId,dataId:sourceid,dataUserId:dataUserId},function(data,status){
											if(data=='true'){
												DownLoad();
												return true;
											}else{
												return false;
											}
										});
									}else{
										return false;
									}
								}else{
									alert("你的积分不够，无法下载！");
									return false;
								}
							});
						}else{
							return false;
						}
					}
					
						//:coffee
						// $ ->
						//  $('#tip-off').modal 'show'
					</script>
					
					<script type="text/javascript">
						function checkLogin(){
							if($.cookie("userId")){
								return true;
							}
							if(confirm("需要登录，是否登录?")){
								var links=top.location.href.substring(7).split("/");
								top.location.href="<%=basePath%>login.jsp?link="+encodeURIComponent(links[2]+"/"+links[3]);
								return false;
							}
							return false;
						}
						(function(){
						$(function(){
							var back_top_value =Math.ceil(document.documentElement.clientHeight *0.65);
							var float_ask_img="<div data-mod='popu_64' class='tracking-ad' chg-blk='0' ><a id='com-ask-float-block' target='_blank' title='文件上传' style='top:"+(back_top_value-41)+"px'></a></div>";
							$("body").append(float_ask_img);
							$("#com-ask-float-block").click(function(){
								if(checkLogin()){
									$(this).attr("href","<%=basePath%>download/upload.jsp");
								}
							});
						});
						})();
						</script>

					<!-- 广告位：资源详细页 头文件下视窗300*250 -->
					<!--AdForward Begin:-->
					<!--AdForward End-->
					<!-- 300*250 -->
				</div>

				<!-- 728*90 -->
				<script src="<%=basePath %>js/jquery.cookie.js"></script>
<!-- 				<script type="text/javascript" src="/js/search-service/main.js" -->
<!-- 					charset="utf-8"></script> -->
				<!-- 728*90 -->
				<a name="comment" style="height:10px;display:inline-block"></a>
				<div class="commend mb-bg">
					<div class="section-list panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">资源评论</h3>
            </div>

            <!-- recommand -->
					 <script language="JavaScript" defer="" type="text/javascript" src="<%=basePath %>js/comment_download.js"></script>

						<div class="recommand download_comment panel-body" sourceid="<%=dataId%>">

<!-- page nav -->
</div>
          </div>
				</div>
				<!-- 728*90 -->
			</div>
		</div>

		<!-- 新 用户开通会员 -->
		<div id="vip-popup" role="dialog" class="modal fade">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button aria-hidden="true" data-dismiss="modal" type="button"
							class="close">×</button>
					</div>
					<div class="modal-body">
						<div class="row">
							<div class="col-xs-1">
								<span class="checkmark"></span>
							</div>
							<div class="col-xs-11">
								<div class="text" id="vip_message"></div>
								<!-- 开通VIP会员权限，免积分下载 -->
								<div class="btns">
									<a href="http://vip.csdn.net" target='_blank'
										class='close_open_vip btn_2 btn btn-primary'>立即开通</a>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- 新end 用户开通会员 -->
		<script type="text/javascript" src="<%=basePath %>js/text-stretch_download.js"></script>
		<!-- //jump windows -->
		<script language='JavaScript' type='text/javascript'
			src='<%=basePath %>js/jquery.form.js'></script>
	</div>
	<link href="<%=basePath %>css/ask_float_block.css"
		rel="stylesheet" type="text/css" />
</body>
</html>
